home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / primeu1a / primer2.frm < prev    next >
Text File  |  1999-05-23  |  4KB  |  126 lines

  1. VERSION 5.00
  2. Begin VB.Form Primer 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "This program will prime you! Watch out!"
  5.    ClientHeight    =   2115
  6.    ClientLeft      =   1980
  7.    ClientTop       =   1440
  8.    ClientWidth     =   4305
  9.    ClipControls    =   0   'False
  10.    Icon            =   "PRIMER2.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    MousePointer    =   1  'Arrow
  15.    PaletteMode     =   1  'UseZOrder
  16.    ScaleHeight     =   2115
  17.    ScaleWidth      =   4305
  18.    Begin VB.CommandButton Primer 
  19.       Caption         =   "&Leave without priming the set of integers."
  20.       Height          =   375
  21.       Left            =   120
  22.       TabIndex        =   2
  23.       Top             =   1560
  24.       Width           =   3495
  25.    End
  26.    Begin VB.ListBox Primes 
  27.       Enabled         =   0   'False
  28.       Height          =   450
  29.       Left            =   120
  30.       MousePointer    =   1  'Arrow
  31.       TabIndex        =   0
  32.       Top             =   960
  33.       Width           =   3135
  34.    End
  35.    Begin VB.Image Image1 
  36.       Height          =   480
  37.       Left            =   120
  38.       Picture         =   "PRIMER2.frx":030A
  39.       Top             =   360
  40.       Width           =   480
  41.    End
  42.    Begin VB.Label John 
  43.       Caption         =   "Press on the magic wand to find a million prime numbers. Warning: this process takes a couple days."
  44.       Height          =   615
  45.       Left            =   720
  46.       TabIndex        =   1
  47.       Top             =   240
  48.       Width           =   3375
  49.       WordWrap        =   -1  'True
  50.    End
  51. End
  52. Attribute VB_Name = "Primer"
  53. Attribute VB_GlobalNameSpace = False
  54. Attribute VB_Creatable = False
  55. Attribute VB_PredeclaredId = True
  56. Attribute VB_Exposed = False
  57. Dim STime
  58. Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
  59. Const MOUSEEVENTF_MOVE = &H1
  60. Const MOUSEEVENTF_ABSOLUTE = &H8000 '  absolute move
  61.  
  62.  
  63. Private Sub Prime()
  64. Dim Factor As Long, Doc As String, H
  65. Dim i As Long, j As Currency, MX As Long
  66. Dim rc
  67.     On Error Resume Next
  68.     MousePointer = 11
  69.     STime = Time
  70.     WindowState = 1
  71.     Primes.Clear
  72.     Primes.AddItem 2
  73.     Primes.AddItem 3
  74.     Doc = "2"
  75.     Me.Enabled = False
  76.     MX = 2
  77.     For i = 3 To 999999 Step 2
  78.         mouse_event MOUSEEVENTF_MOVE, 0, 0, 0, 0
  79.         For j = 1 To Primes.ListCount - 1
  80.             If Primes.List(j) > i / 2 Then GoTo 1
  81.             H = Primes.List(j)
  82.             If i \ H = i / H Then
  83.                 GoTo 0
  84.             ElseIf i \ H <> i / H Then
  85.                 If j = Primes.ListCount - 1 Then
  86. 1                   Primes.AddItem i
  87.                     Doc = Doc & " " & i
  88.                     MX = i
  89.                     Caption = MX
  90.                     GoTo 0
  91.                 End If
  92.             End If
  93.         Next j
  94. 0   Next i
  95.     Beep
  96.     Me.Enabled = True
  97.     Clipboard.SetText Doc
  98.     Caption = STime - Time
  99.     MousePointer = 1
  100.     John = "You have just primed the set of Computer Integers."
  101.     Caption = "&Leave after priming the set of integers."
  102.     Visible = True
  103.     WindowState = 0
  104. End Sub
  105.  
  106. Private Sub Image1_Click()
  107. Dim i
  108.     Primes.Enabled = True
  109.     John = "Priming the set of integers; Please wait."
  110.     Prime
  111. End Sub
  112.  
  113. Private Sub Primer_Click()
  114.     End
  115. End Sub
  116.  
  117. '''''''''''''''''''''''''
  118. '   1  999   999   6    '
  119. ' 1 1 9   9 9   9 6     '
  120. '   1  9999  9999 6666  '
  121. '   1     9     9 6   6 '
  122. ' 11111  9     9   666  '
  123. '''''''''''''''''''''''''
  124. '   Feucht Production   '
  125. '''''''''''''''''''''''''
  126.